package com.naiterui.ehp.bs.doctor.vo.medicine;

import com.naiterui.ehp.bp.utils.lang.ConfigUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@ApiModel(value = "MedicineDosageVO", description = "用量列表")
public class MedicineDosageVO implements Serializable {

    /**
     * 字段或域定义：<code>serialVersionUID</code>
     */
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用量字符串:每日1次")
    private String dosageStr;

    @ApiModelProperty(value = "日期数:3天，4周等")
    private Integer dateNumber;

    @ApiModelProperty(value = "日期单位:小时，日，周等")
    private String dataUnit;

    @ApiModelProperty(value = "次数:1次，2次等")
    private Integer frequency;

    @ApiModelProperty(value = "次数值")
    private Double frequencyValue;

    public String getDosageStr() {
        return this.dosageStr;
    }

    public void setDosageStr(String dosageStr) {
        this.dosageStr = dosageStr;
    }

    public Integer getDateNumber() {
        return this.dateNumber;
    }

    public void setDateNumber(Integer dateNumber) {
        this.dateNumber = dateNumber;
    }

    public String getDataUnit() {
        return this.dataUnit;
    }

    public void setDataUnit(String dataUnit) {
        this.dataUnit = dataUnit;
    }

    public Integer getFrequency() {
        return this.frequency;
    }

    public void setFrequency(Integer frequency) {
        this.frequency = frequency;
    }

    public Double getFrequencyValue() {
        return frequencyValue;
    }

    public void setFrequencyValue(Double frequencyValue) {
        this.frequencyValue = frequencyValue;
    }

    public static List<MedicineDosageVO> toVOList() {
        String dosageList = ConfigUtil.getString("init.medicine.dosageList");
        List<MedicineDosageVO> list = new ArrayList<>();
        String[] strArray = dosageList.split(",");
        for (String aStrArray : strArray) {
            String[] str = aStrArray.split("-");
            MedicineDosageVO vo = new MedicineDosageVO();
            vo.setDosageStr(str[0]);
            vo.setDateNumber(Integer.parseInt(str[1]));
            vo.setDataUnit(str[2]);
            vo.setFrequency(Integer.parseInt(str[3]));
            vo.setFrequencyValue(Double.parseDouble(str[4]));
            list.add(vo);

        }
        return list;
    }
}
